<?php

namespace App\Http\Controllers\BaseSet;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use App\accouts;
use Validator;

class ParameterController extends Controller
{
    public function index(){
        return view('BaseSet.Parameter.index');
    }
    /*/
     * 获取微信号参数
     */
    public function getParameter(Request $request)
    {
        $input=$request->all();
        $rules=[
            'accout_name' => 'required|unique:accouts',
            'accout_id'=>'required|unique:accouts',
            'wx_name'=>'required|unique:accouts',
            'appid'=>'required|unique:accouts',
            'appsecret'=>'required',
            'pwd_way'=>'required',
            'token'=>'required',
            'key'=>'required',
            'type'=>'required',
            'url'=>'required',
        ];

        $validator = Validator::make($input, $rules);

       if ($validator->fails()) {
           return redirect('BaseSet/Parameter')
                ->withErrors($validator);
        }

       accouts::create($request->all());
       // $success='公众号添加成功';
        return redirect('BaseSet/Parameter')->with(['success'=>'公众号添加成功']);
    }

}
